-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow identifiers to be defined with a block #110
Allow identifiers to be defined with a block #110
Conversation
|
||
def self.inherited(subclass) | ||
subclass.send(:view_collection).inherit(view_collection) | ||
def self.identifier(method, name: method, extractor: AutoExtractor.new, &block) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding to the method documentation for this and adding it to the README similar to how you did for the associations?
https://github.com/procore/blueprinter/blob/f849049fedf7adea5f13d11b2514b6c8b54f7efa/lib/blueprinter/base.rb#L124-L139
https://github.com/procore/blueprinter/blob/master/README.md#defining-an-association-directly-in-the-blueprint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
def self.inherited(subclass) | ||
subclass.send(:view_collection).inherit(view_collection) | ||
end | ||
private_class_method :inherited |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch!
Now that `::association` and `::field` receive an optional block, `::identifier` should receive it as well. Since all three methods receive an optional block, the block extraction mechanism was moved to `AutoExtractor`. Removing this mechanism from each individual method made them very similar. `::association` now uses `::field` instead of directly adding the field to the current view.
fa9f3ff
to
22b04ff
Compare
I've added documentation. Feel free to suggest better examples, I used the one I needed on my project, but it may be a bit weird. |
LGTM! |
We’ll hopefully get this out soon in the next release of Blueprinter, thanks for this! |
Now that
::association
and::field
receive an optional block,::identifier
should receive it as well.Since all three methods receive an optional block, the block extraction
mechanism was moved to
AutoExtractor
. Removing this mechanism fromeach individual method made them very similar.
::association
now uses::field
instead of directly adding the field to the current view.Addresses #109